﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace EWDT_Lab_Demo
{
    public partial class Default : System.Web.UI.Page
    {
        private void Page_Init(object sender, EventArgs e)
        {
            //This event does nothing. It is meant to highlight the life cycle of a ASP.NET page
            bool temp = false;
            if (temp) { }
        }

        private void Page_PreRender(object sender, EventArgs e)
        {
            //This event does nothing. It is meant to highlight the life cycle of a ASP.NET page
            bool temp = false;
            if (temp) { }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //Let's check if the user has logged on and display the appropriate greeting to the user.
                if (Context.User.Identity.Name != "")
                {
                    lblGreeting.Text = "You have been successfully authenticated. System menu is now visible for your use.";
                }
                else
                {
                    lblGreeting.Text = "This is the first page that any visitor, including guests will see. <br><br>The system menu will NOT be displayed.";
                }

                //We detected an unauthenticated user trying to access a protected webpage. Display the ACCESS DENIED message to the user.
                if (Request.QueryString["ReturnUrl"] != null)
                {
                    lblGreeting.Text = "<br><img src='http://winwebhosting.net/wp-content/uploads/2009/05/accessdenied.gif'><br>You have tried accessing a webpage that is available only to authorised users. Please login.";
                }
            }
        }
    }
}